<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/js/flatpickr.min.css" />
		<link rel="stylesheet" type="text/css" href="/bootstrap-3.3.7/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/dialog/css/dialog.css" />
		<link rel="stylesheet" type="text/css" href="/css/font-awesome.css" />
		<link rel="stylesheet" type="text/css" href="/css/bootstrap-datetimepicker.min.css" />
		<link rel="stylesheet" type="text/css" href="/css/pager.css" />
		<link rel="stylesheet" href="/css/shoufengqin.css">
		<link rel="stylesheet" type="text/css" href="/css/haha.css" media="screen" />
		<link rel="stylesheet" href="/css/b.page.bootstrap3.css" type="text/css"/>
	</head>

	<body>
    <nav class="topNavItemBox">
        <div id="ItemBox">
            <div class="title">智慧溯源系统</div>
            <div class="subtitle">肉品溯源管理</div>
            <div class="rightUserInfo">
                <div class="commentAvatarDiv">
                    <img class="commentAvatarImage" src="/images/people.jpg">
                </div>
                <div class="userName">
					<#if Session.curEmployeeInfo??>
                        <a href="/admin/logout">${Session.curEmployeeInfo.emName}</a>
					</#if>
                </div>
                <span class="glyphicon glyphicon-option-vertical userIcon" aria-hidden="true"></span>
            </div>
        </div>
    </nav>
        <div class="contain">
        	<#include "leftPage.ftl">
			</div>
			<div id="middle1" class="page_main">
				<div id="middle2" class="page_content">
					<div class="buttonGroup">
						<a href="/admin/Feeding/toAdd" class="btn btn-primary btn-sm" >添加养殖信息</a>
						<a class="btn btn-danger btn-sm" onclick="deleteByids()">批量删除</a>
					</div>
					<div class="searchGroup">
						<form method="post" action="/admin/Feeding/findByCondition">
							<span>生猪编号&nbsp;</span><input type="text" placeholder="请输入生猪编号" value="${purGid}" name="purGid" class="bigInputtext">
							<span>开始日期&nbsp;</span><input type="text" placeholder="请选择查找起始时间" id="begin" name="beginTime" class="bigInputtext"><br/>
							<span>结束时间&nbsp;</span><input type="text" placeholder="请选择查找结束时间" id="end" name="endTime" class="bigInputtext">
							<span><button type="submit" class="btn btn-info btn-sm">搜索</button></span>
                        </form>
					</div>
					
					<table class="table table-striped table-bordered table-hover table-condensed">
						<thead>
							<tr>
								<th class="selectColumn" ><input type="checkbox" onclick="selectAll()" id="allSelect"></th>
                                <th >信息编号</th>
                                <th >饲养企业</th>
                                <th>饲养区域</th>
                                <th >生猪编号</th>
                                <th >饲料用量</th>
                                <th >饲料单位</th>
                                <th>饲养时间</th>
                                <th >喂养人</th>
                                <th >备注</th>
                                <th >操作</th>
							</tr>
						</thead>
						<tbody>
							<#list pageInfo.list as  FeedingInfoVO>
								<tr>
									<td class="selectColumn"><input type="checkbox" name="isCheck" value="${FeedingInfoVO.feedingInfor.feedingid}"/></td>
                                    <td>${FeedingInfoVO.feedingInfor.feedingid} </td>
                                    <td >${FeedingInfoVO.companyInfo.compname}</td>
                                    <td >${FeedingInfoVO.feedingInfor.areaid} </td>
                                    <td>${FeedingInfoVO.feedingInfor.animalid}</td>
                                    <td >${FeedingInfoVO.feeds.feedname}</td>
                                    <td >${FeedingInfoVO.feedingInfor.foodamount?string("0.##")}${FeedingInfoVO.feedingInfor.foodunit}</td>
                                    <td >${(FeedingInfoVO.feedingInfor.feedingtime?string('yyyy-MM-dd'))}</td>
                                    <td >${FeedingInfoVO.employeeInfo.emName}</td>
                                    <td >${FeedingInfoVO.feedingInfor.remark}</td>
									<td width="140">
										<div class="tableButtonGroup">
											<a class="btn btn-info btn-sm" href="/admin/Feeding/toedit?gid=${FeedingInfoVO.feedingInfor.feedingid}">修改</a>
											<button type="button" class="btn btn-danger btn-sm" onclick="JavaScript:if(confirm('是否删除')){ delete1(${FeedingInfoVO.feedingInfor.feedingid})}">删除</button>
										</div>
									</td>
								</tr>
							</#list>
						</tbody>
					</table>
					<div class="paginationFoot">
						                        <#if pageInfo.pages == 1  >
                                                    第 ${pageInfo.pageNum} / ${pageInfo.pages}页
                                                <#elseif "pageInfo.pages > 1 " >
                                                    <#if pageInfo.pageNum == 1>
                                   <a href="/admin/Feeding/findByCondition?pageNumber=${pageInfo.pageNum+1}" >下一页</a>  第  ${pageInfo.pageNum}/${pageInfo.pages}页
                                                    <#elseif pageInfo.pageNum == pageInfo.pages>
                                       <a href="/admin/Feeding/findByCondition?pageNumber=${pageInfo.pageNum-1}" >上一页</a>  第  ${pageInfo.pageNum}/${pageInfo.pages}页
                                                    <#else>
                                      <a href="/admin/Feeding/findByCondition?pageNumber=${pageInfo.pageNum-1}" >上一页</a>
                                      <a href="/admin/Feeding/findByCondition?pageNumber=${pageInfo.pageNum+1}" >下一页</a>   第  ${pageInfo.pageNum}/${pageInfo.pages}页
                                                    </#if>
                                                </#if>
					</div>
				</div>
			</div>
		
		</div>
		<div class="footer">
			<div class="footer_lineone">
				<span id="logo"></span>肉品溯源管理系统 
				<span class="footer_lineoneSpan"><a href="aboutus.html">关于我们</a></span>
				<span class="footer_lineoneSpan"><a target="_blank" href="http://www.cfsiw.com/">食品安全信息</a></span> 
				<span class="footer_lineoneSpan"><a href="suggestionAdd.ftl">联系我们</a></span>
			</div>
			<div class="footer_linetwo">
				 &copy;2017广东技术师范学院
			</div>
		</div>	

		<script src="/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/google-maps.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/jquery.form.js"></script>
		<script src="/dialog/js/dialog.js"></script>
		<script src="/js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/bootstrap-datetimepicker.js" type="text/javascript" charset="utf-8"></script>
		<script src="/laydate/laydate.js"></script> <!-- 改成你的路径 -->
		<script type="text/javascript" src="/js/b.page.js" ></script>
		<script src="/js/pager.js"></script>
		<script src="/js/shoufengqin.js"></script>
		<script src="/js/flatpickr.js"></script>
        <script type="text/javascript" charset="UTF-8">
            //全选、全不选
            function selectAll() {
                if ($("#allSelect").is(":checked")) {
                    $("input[name='isCheck']").prop("checked",true);
                } else {
                    $("input[name='isCheck']").prop("checked",false);
                }
            }


            /*异步删除*/
            function delete1(id) {
                $.ajax({
                    type:'post',
                    url:'/admin/Feeding/delete',
                    data:{
                        id : id
                    },
                    success:function(data) {
                        if(data == 1){
                            document.location.reload();
                        }else{
                            alert("删除失败");
                        }
                    }
                });
            }


			// /批量删除
            function deleteByids() {
                var option = $("input[name='isCheck']:checked");
                var ids = "";
                for (var i = 0; i< option.length;i++){
                    if(i == 0){
                        ids += option[i].value;
                    }else{
                        ids += "," + option[i].value;
                    }
                }
                $.dialog({
                    type: 'confirm',
                    contentHtml: '<p style:"magrin:0 auto">确认删除？</p>',
                    onClickOk: function() {
                        $.ajax({
                            url: "/admin/Feeding/deletes",
                            data: {
                                'ids': ids
                            },
                            error: function(XMLHttpRequest, textStatus, errorThrown) {
                                //弹失败框
                                $.dialog({
                                    type: 'info',
                                    contentHtml: '<img class="info-icon" src="/dialog/images/icon/fail.png" alt="删除失败" /><p class="info-text">删除失败</p>',
                                    autoClose: 1000
                                });
                            },
                            success: function() {
                                //弹成功框
                                $.dialog({
                                    type: 'info',
                                    contentHtml: '<img class="info-icon" src="/dialog/images/icon/success.png" alt="删除成功" /><p class="info-text">删除成功</p>',
                                    autoClose: 1000
                                });
                                setTimeout("window.location.reload();",1000);
                            }
                        });
                    }
                });
            }

            $(function() {
                //初始化侧边栏
                $(".vertical-nav").verticalnav({
                    speed: 400,
                    align: "left"
                });

                //时间选择组件1
                laydate.render({
                    elem: '#begin' //指定元素
                });

                //时间选择组件2
                laydate.render({
                    elem: '#end' //指定元素
                });


                //分页组件
                Page({
                    num:7,					//页码数
                    startnum:6,				//指定页码
                    elem:$('#page2'),		//指定的元素
                    callback:function(n){	//回调函数
                        console.log(n);
                    }
                });

                jQuery(document).ready(function($)
                {
                    $('.list22 ul li p').clickdown();
                    $('.list-se p[class=title22]').clickup();
                    $('.list22>ul>li').ad();
                });
            });
        </script>
	</body>
	<style type="text/css">
		#test1{
			width: 155px;
			height: 30px;
		}
		.buttonGroup{
			display: inline-block;
			margin-bottom: 20px;
		}
		.searchGroup{
			display: inline-block;
			float: right;
		}
		.tableButtonGroup{
			text-align: center;
		}
		.paginationFoot{
			text-align: center;
		}
		.contain{
			overflow: hidden;
		}
		.contain #middle1{
            width:100%;
            margin-left:-200px;
            float:left;
            overflow: hidden;
        }
        .contain #middle2{
            margin-left: 280px;
    		margin-right: 30px;
        }
        .contain .left1{
            width:200px;
            float:left;
            min-width: 200px;
        }
	</style>
</html>